package com.ruoyi.inventory.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.page.Pages;
import com.ruoyi.common.core.page.Query;
import com.ruoyi.common.query.QueryTool;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.inventory.mapper.DeliveryDetailMapper;
import com.ruoyi.inventory.domain.DeliveryDetail;
import com.ruoyi.inventory.service.IDeliveryDetailService;

/**
 * 配货单-明细Service业务层处理
 * 
 * @author xwj
 * @date 2024-11-10
 */
@Service
public class DeliveryDetailServiceImpl extends ServiceImpl<DeliveryDetailMapper, DeliveryDetail> implements IDeliveryDetailService {
    @Autowired
    private DeliveryDetailMapper deliveryDetailMapper;

    /**
     * 查询配货单-明细
     * 
     * @param id 配货单-明细主键
     * @return 配货单-明细
     */
    @Override
    public DeliveryDetail selectDeliveryDetailById(Long id) {
        return deliveryDetailMapper.selectDeliveryDetailById(id);
    }

    /**
     * 查询配货单-明细列表
     * 
     * @param deliveryDetail 配货单-明细
     * @return 配货单-明细
     */
    @Override
    public List<DeliveryDetail> selectDeliveryDetailList(DeliveryDetail deliveryDetail) {
        return deliveryDetailMapper.selectDeliveryDetailList(deliveryDetail);
    }

    /**
     * 新增配货单-明细
     * 
     * @param deliveryDetail 配货单-明细
     * @return 结果
     */
    @Override
    public DeliveryDetail insertDeliveryDetail(DeliveryDetail deliveryDetail) {

      //  deliveryDetailMapper.insertDeliveryDetail(deliveryDetail);
    save(deliveryDetail);
    return deliveryDetail;
    }

    /**
     * 修改配货单-明细
     * 
     * @param deliveryDetail 配货单-明细
     * @return 结果
     */
    @Override
    public DeliveryDetail updateDeliveryDetail(DeliveryDetail deliveryDetail) {

      //  deliveryDetailMapper.updateDeliveryDetail(deliveryDetail);
        updateById(deliveryDetail);
        return deliveryDetail;
    }

    /**
     * 批量删除配货单-明细
     * 
     * @param ids 需要删除的配货单-明细主键
     * @return 结果
     */
    @Override
    public int deleteDeliveryDetailByIds(Long[] ids) {
        return deliveryDetailMapper.deleteDeliveryDetailByIds(ids);
    }

    /**
    * 条件删除
    * @param deliveryDetail 配货单-明细
    * @return
    */
    @Override
    public int delete(DeliveryDetail deliveryDetail) {
        QueryWrapper<DeliveryDetail> qw = new QueryWrapper<>();
        QueryTool.condition(qw, deliveryDetail);
        return baseMapper.delete(qw);
    }

    /**
     * mp分页
     * @param deliveryDetail 配货单-明细
     * @return
     */
    @Override
    public Pages<DeliveryDetail> queryPage(DeliveryDetail deliveryDetail) {
        QueryWrapper<DeliveryDetail> qw = new QueryWrapper<>();
        QueryTool.condition(qw, deliveryDetail);
        IPage<DeliveryDetail> ipage = new Query<DeliveryDetail>().getPage(deliveryDetail);

        IPage<DeliveryDetail> page = this.page(
                ipage,
                qw
        );
        return new Pages<>(page);
    }

    @Override
    public void deleteDeliveryDetailByDeliveryIds(Long[] deliveryIds) {
        deliveryDetailMapper.deleteDeliveryDetailByDeliveryIds(deliveryIds);
    }

    /**
     * 删除配货单-明细信息
     * 
     * @param id 配货单-明细主键
     * @return 结果
     */
    @Override
    public int deleteDeliveryDetailById(Long id) {
        return deliveryDetailMapper.deleteDeliveryDetailById(id);
    }
}
